package com.gem.day09.homework;

public class Answer2 {

	static StringBuilder builder;

	static {
		builder = new StringBuilder();
		builder.append("This is a log file,it was store at").append("\"d:\\Program File\\temp\" ")
				.append("directory.the format of log file was:\n").append("20130509:Jack:M:1990-08-08");
	}

	public static void main(String[] args) {
		//截取此内容中的路径子字符串
		int start = builder.indexOf("\"");
		int end = builder.indexOf("\"", start + 1);
		String result1 = builder.substring(start + 1, end);
		System.out.println(result1);

		//把第一个引号之前的部分中的所有空格替换为#
		//把第二个引号之后的部分中的所有空格替换为*
		String firstPartString = builder.substring(0, start + 1).replace(" ", "#");
		String secondPathString = builder.substring(end).replace(" ", "*");
		String result2 = firstPartString + result1 + secondPathString;
		System.out.println(result2);

		//把\n后面的字符串取出打印
		String lastPathString = builder.substring(builder.lastIndexOf("\n") + 1);
		System.out.println(lastPathString);

		//以:作为切割符,把\n后面截取出来的字符串分段打印
		String[] strArr = lastPathString.split(":");
		for (String str : strArr) {
			System.out.println(str);
		}
	}
}